﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;

namespace Niknak.Services.TaskScheduler.Wcf
{
    [Serializable]
    public class SerializableEventRecord
    {
        public Guid? ActivityId { get; set; }
        public int Id { get; set; }
        public long? Keywords { get; set; }
        public IEnumerable<string> KeywordsDisplayNames { get; set; }
        public byte? Level { get; set; }
        public string LevelDisplayName { get; set; }
        public string LogName { get; set; }
        public string MachineName { get; set; }
        public short? Opcode { get; set; }
        public string OpcodeDisplayName { get; set; }
        public int? ProcessId { get; set; }
        public Guid? ProviderId { get; set; }
        public string ProviderName { get; set; }
        public int? Qualifiers { get; set; }
        public long? RecordId { get; set; }
        public Guid? RelatedActivityId { get; set; }
        public int? Task { get; set; }
        public string TaskDisplayName { get; set; }
        public int? ThreadId { get; set; }
        public DateTime? TimeCreated { get; set; }
        public byte? Version { get; set; }
        public string Description { get; set; }

        public SerializableEventRecord(EventRecord fromEvent)
        {
            if (fromEvent == null)
                return;

            this.ActivityId = fromEvent.ActivityId;
            this.Id = fromEvent.Id;
            this.Keywords = fromEvent.Keywords;
            this.KeywordsDisplayNames = fromEvent.KeywordsDisplayNames;
            this.Level = fromEvent.Level;
            this.LevelDisplayName = fromEvent.LevelDisplayName;
            this.LogName = fromEvent.LogName;
            this.MachineName = fromEvent.MachineName;
            this.Opcode = fromEvent.Opcode;
            this.OpcodeDisplayName = fromEvent.OpcodeDisplayName;
            this.ProcessId = fromEvent.ProcessId;
            this.ProviderId = fromEvent.ProviderId;
            this.ProviderName = fromEvent.ProviderName;
            this.Qualifiers = fromEvent.Qualifiers;
            this.RecordId = fromEvent.RecordId;
            this.RelatedActivityId = fromEvent.RelatedActivityId;
            this.Task = fromEvent.Task;
            this.TaskDisplayName = fromEvent.TaskDisplayName;
            this.ThreadId = fromEvent.ThreadId;
            this.TimeCreated = fromEvent.TimeCreated;
            this.Version = fromEvent.Version;

            this.Description = fromEvent.FormatDescription();
        }
    }
}
